import router from '@/router'
import { getItem } from '@/utils/token-utils'
import { Toast } from 'tdesign-mobile-vue'

const whiteList = ['/login']


router.beforeEach(async (to, from, next) => {

    let uuid = getItem('uuid')
    let token = getItem('token')

    if (!(!!uuid && !!token)) {
        if (whiteList.indexOf(to.path) !== -1) {
            next()
        }else{
            Toast('Đã hết hạn hạ cánh, xin vui lòng hạ cánh lại')
            next('/')
        }
    } else {
        next()
    }
})
